package com.study.leetcode;

public class _62 {
    public int uniquePaths(int m, int n) {
        return path(m, n, new int[m][n]);
    }

    public int path(int m, int n, int[][] cache) {

        cache[0][0] = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0 || j == 0) {
                    cache[i][j] = 1;
                } else {
                    cache[i][j] = cache[i - 1][j] + cache[i][j - 1];
                }
            }
        }

        return cache[m - 1][n - 1];
    }

    public static void main(String[] args) {
        _62 v = new _62();

        int i = v.uniquePaths(3, 7);
        System.out.println(i);
    }
}
